<#--<script type="text/javascript" src="/js/jquery/jquery.js"></script>
<script type="text/javascript" src="/js/system/common.js"></script>-->

<div class="hd">
    <span id="_j_anum">${page.totalElements!0}</span>个回答
</div>
<style>
    a{
        text-decoration:none ;
    }
    a:hover{
        text-decoration:underline ;
    }

</style>
<script>
    $(function () {
        $("._js_showShare").click(function () {
            alert("恭喜您,分享成功!")
        })

        $(".jubao").click(function () {
            alert("不好意思,本评论拥有最高权限,举报我? 你怕不是在想屁吃")
        })

        //顶
        $("._j_support_btn").click(function(){
            console.log(1);
            var uid = $(this).data("uid");
            var aid = $(this).data("aid");
            $.get("/wenda/wendaThumbsup",{uid:uid,aid:aid},function(data){
                if (data.success) {
                    $(".a").html(data.data.thumbupnum);
                    alert("顶成功啦"); //

                } else {
                    if (data.code == 102) {
                        alert(data.msg);
                    } else {
                        alert("今天你已经顶过了"); //
                    }
                }
            })
        })
    })

</script>

<ul class="answer-list ">
    <!-- 回答列表 -->
    <div id="normal_answer_wrap" class="pagelet-block"
         data-controller="/js/qa/ControllerDetailAnswerList">


        <#list page.content as entity>
            <li class=" answer-item clearfix _j_answer_item _js_answer18529696 _js_answer_dealing"
                data-aid="${entity.id}">
                <#--  <div class="answer-side _js_answerAva">
                      <a class="btn-ding _js_zan  click"><i></i><span data-real_num="1">2</span></a>
                  </div>-->

                <div class="answer-content _js_answer_content">
                    <div class="answer-info clearfix">

                        <#-- 用户信息 -->
                        <div class="user-bar fl">

                            <a class="_j_filter_click avatar" href="/wenda/u/58018810/answer.html" target="_blank">
                                <img src="${(entity.headUrl)!}" width="48" height="48" class="photo">
                            </a>
                            <a class="name" href="/wenda/u/58018810/answer.html"
                               target="_blank">${(entity.username)!}</a>
                            <a class="level" href="/rank/lv.php?uid=58018810" target="_blank"
                               rel="nofollow">LV.${(entity.level)!}</a>

                            <#-- <a class="identity i-guide" href="/qa/expert_apply.php?type=1"
                                target="_blank">指路人</a>
                             <a class="identity i-goldmedal">金牌大师</a>-->
                        </div>

                        <#-- <ul class="answer-medal fr">
                             <li class="gold">
                                 <div class="btn"><i></i><a href="/i/3136909.html" target="_blank">金牌回答</a></div>
                             </li>
                         </ul>-->
                    </div>

                    <!-- 回答内容 -->
                    <div class="_j_long_answer_item">
                        <div class="_j_answer_html">
                            ${(entity.content)!}
                            <br>==========<br>
                            <br>
                            如果你觉得TA的回答不错，快来给TA点个赞吧！<br>
                            你的支持是对作者莫大的鼓励~
                        </div>
                        <div class="answer-side _js_answerAva">
                            <a class="btn-ding  _j_support_btn" title="顶" data-aid="${entity.id}" data-uid="${(userInfo.id)!}" href="javascript:;"><i></i><span class="a">${(entity.thumbupnum)!}</span></a>
<#--                            <a class="btn-ding  _j_support_btn" title="顶" data-qid="${entity.id}" data-uid="${(userInfo.id)!}" href="javascript:;"><i></i><span class="a">${(entity.thumbupnum)!}</span></a>-->

                        </div>


                        <#--<div class="answer-side _j_ding_father">
                            <a href="javascript:;" class="_j_support_btn btn-ding _js_zan" title="顶" data-tid="${(question.id)!}"><i class="i05 "></i></a>
                            <div class="num _j_up_num topvote12655354">${(question.thumbsupnum)!}</div>
                        </div>-->
                    </div>
                </div>

                <!-- 问答版权名片 -->
                <div class="a-operate _js_operate clearfix">
                    <div class="fl">
                        <div class="q-share cate-share">
                            <a class="_js_showShare"><i class="q-share-icon"></i>分享</a>

                            <!-- <div class="share-pop _j_share_pop hide clearfix" data-title="男朋友月薪6000，让他带我去旅行花5000，过分吗？" data-qid="18469136" data-aid="18481227">
                                 <a title="分享到新浪微博" class="sina _j_do_share" data-site="wb" data-username="马蜂窝里的东成"></a>
                                 <a title="分享到QQ空间" class="zone _j_do_share" data-site="qz" data-username="马蜂窝里的东成"></a>
                                 <a title="分享到微信" class="weixin _j_do_share_wx" data-site="wx" data-username="马蜂窝里的东成"></a>
                             </div>-->
                        </div>
                        <div class="cmt-toggle">
                            <a class="_js_slideComment" data-cnum="0"
                               data-default_words="举报按钮"><i></i><span>有本事你举报我啊==></span></a>
                        </div>
                        <#--<div class="collect">
                            <a role="button" class="btn-like" &lt;#&ndash;data-tid="${(question.id)!}&ndash;&gt;" href="javascript:;"><i></i>点赞</a>&lt;#&ndash;${(question.thumbsupnum)!}&ndash;&gt;
                        </div>-->


                        <div class="pub-time">
                            <span>发布于 ${entity.createTime?string("yyyy-MM-dd hh:mm:ss")}</span>
                        </div>
                        <div class="tip-off">
                            <a data-japp="report"
                               data-refer="http://www.mafengwo.cn/wenda/detail-18469136.html#answer18506995"
                               data-refer-uid="58018810" data-app="qa.answer"
                               data-busi-id="aid:18506995" class="jubao">举报</a>
                        </div>
                    </div>
                </div>


                <#-- 评论 区域 -->
                <#--<div class="comment-wrap _js_comments is_foldup_detail">
                    <b class="arrow"><i></i></b>


                    &lt;#&ndash;  评论列表回显数据  &ndash;&gt;
                    <div class="_js_comment_list">
                        <ul class="comment-list _j_comment_list_ul " data-id="${entity.id}">-->

                            <#--<#list entity. as c>

                                <li class="comment-item clearfix">

                                    &lt;#&ndash; 评论相关用户信息 &ndash;&gt;
                                    <div class="comment-user">
                                        <a href="/u/81730598.html" target="_blank">
                                            <img src="${c.headUrl}" class="photo">
                                        </a>
                                    </div>

                                    <dl>
                                        <dt>
                                            <a href="/u/81730598.html" target="_blank" class="c-name">${c.username}</a>

                                            <a href="javascript:;" class="level" target="_blank">LV.${c.level}</a>
                                             :  ${c.content}
                                        </dt>
                                        <dd>
                                            <#if c.type==1>
                                                <div class="c-quote">
                                                    <p>
                                                        @${c.refComment.username} :  ${c.refComment.content}
                                                    </p>
                                                </div>
                                            </#if>

                                            <div class="c-info">
                                                <span class="c-time fl">${c.createTime?string("yyyy-MM-dd hh:mm:ss")}</span>
                                                <span class="c-like">
                                                    <a class="btn-like
                                                            ${c.thumbuplist?seq_contains((userInfo.id)!)?string("on", "")}"
                                                            data-toid="${c.id}" data-fromid="${(userInfo.id)!-1}">
                                                    </a> ${(c.thumbupnum)!}
                                                </span>


                                                &lt;#&ndash; _j_publish_reply  fr  c-reply&ndash;&gt;
                                                <a class="replyBtn fr c-reply" data-touser="${c.username!}"
                                                   data-toid="${c.id!}" data-aid="${entity.id}" href="javascript:void(0);" onclick="replyBtnClick(this)">回复</a>

                                                <a class="_j_delete_comment fr"  href="javascript:void(0);"
                                                   data-cid="${c.id!}" data-uid="${c.userId!}">删除</a>


                                                <script>

                                                </script>

                                                <a class="c-report fr" data-japp="report"
                                                   data-refer="http://www.mafengwo.cn/wenda/detail-18469136-18481227.html"
                                                   data-refer-uid="81730598" data-app="qa.answer.comment"
                                                   data-busi-id="cid:18502022">举报</a>

                                                <a class="c-replyList" data-japp="qa_reply_list"
                                                   data-rid="18486171" data-aid="18481227">查看对话</a>
                                            </div>
                                        </dd>
                                    </dl>
                                </li>
                            </#list>-->

                 <#--       </ul>
                    </div>-->


                    <#--<div class="comment-page _js_comment_pagination hide" data-comment_total="2"></div>-->

                    <#--&lt;#&ndash; 评论选择框 &ndash;&gt;
                    <div class="comment-add clearfix _j_word">

                        <form action="/wenda/addAnswerComment" method="post" id="commentForm_${entity.id}">
                            <input type="hidden" name="answerId" value="${entity.id!}">
                            <input type="hidden" name="type" value="0" id="commentType">
                            <input type="hidden" name="refComment.id" id="refCommentId">

                            <textarea class="_j_content commentContent_${entity.id}"  name="content" style="width: 100%;" placeholder=""></textarea>

                        </form>
                        &lt;#&ndash;<span class="word-count">
                        <span class="_j_word_num">0</span>/
                        <span class="_j_max_num">600</span> 字&ndash;&gt;
                    </span>
                        &lt;#&ndash;<input class="btn-comment _j_publish_comment commentBtn" data-aid="${entity.id}"  type="button" value="回复">&ndash;&gt;
                    </div>-->
              <#--  </div>-->

            </li>
        </#list>
    </div>
</ul>

<div style="float: right">
    <div style="float: left;" ><span style="line-height:30px"> 共${page.totalPages!}页 / ${page.totalElements}条&nbsp;&nbsp;&nbsp;</span></div>
    <div id="pagination" class="jq-pagination" style="display: inline;"></div>
</div>

<script>
    $("#pagination").jqPaginator({
        totalPages: ${page.totalPages!0},
        visiblePages: 5,
        currentPage: ${page.number+1}||1,
        prev: '<a class="prev" href="javascript:void(0);">上一页<\/a>',
        next: '<a class="next" href="javascript:void(0);">下一页<\/a>',
        page: '<a href="javascript:void(0);">{{page}}<\/a>',
        last: '<a class="last" href="javascript:void(0);" >尾页<\/a>',
        onPageChange: function(page, type) {
        if(type == 'change'){
            $("#currentPage").val(page);
            $("#answerSearchForm").submit();
        }
    }
    })
</script>



<script>

    function replyBtnClick(ele){
        var touser = $(ele).data("touser"); // 评论用户的名字
        var toid = $(ele).data("toid"); // 评论id
        var aid = $(ele).data("aid");

        $(".commentContent_"+aid).focus();
        $(".commentContent_"+aid).attr("placeholder", "回复：" + touser);

        $("#commentForm_"+aid+" #commentType").val(1);
        $("#commentForm_"+aid+" #refCommentId").val(toid);
    }

    $(function () {


        //发表回答对应一个回复框: 获取回复框时，需要自定义的回复框传递的answerid，区分是对应哪一条回复数据
        $(".commentBtn").click(function () {
            var aid=$(this).data("aid");
            if (!$(".commentContent_"+aid).val()) {
                popup("评论不能为空");
                return;
            }
            $("#commentForm_"+aid+"").ajaxSubmit(function (data) {
                $(".commentContent_"+aid).val("");
                $(".commentContent_"+aid).attr("placeholder", "");
                // $("._j_comment_list_ul[data-id="+aid+"]").append(data);
                $("#answerSearchForm").submit();
            })
        })

        //点赞
        $(".btn-like").bind("click",function () {
            var cid = $(this).data("cid");
            var uid = $(this).data("uid");
            $.get("/wenda/commentThumbUp", {cid:cid, uid:uid}, function (data) {
                $("#answerSearchForm").submit();
            })
        })


        $("._j_delete_comment").bind("click",function () {
            var cid = $(this).data("cid"); // 评论id
            var uid = $(this).data("uid"); // 评论用户的id
            console.log(cid+"------"+uid);
            // 发送删除异步请求
            $.get("/wenda/deleteAnswerComment", {uid:uid, commentId:cid}, function (data) {
                if(data.code==102){
                    popup(data.msg);
                    return;
                }
                $("#answerSearchForm").submit();
            })
        })
        //跳转的时候到页面的顶端
        window.scrollTo(0,document.body.scrollHeight);
        window.scrollTo(0,0);
    })

</script>
